import redis from '../config/redisConfig';


/**
 * @param key
 * @param val
 * @param seconds 过期时间，单位秒
 * */
export const setRedis = async (key: string, val: string, seconds?: number): Promise<'OK' | null> => {
  if (seconds) {
    return redis.set(key, val, 'EX', seconds);
  }
  return redis.set(key, val);
};

export const getRedis = async (key: string): Promise<string | null> => {
  return redis.get(key);
};

export const delRedis = async (key: string): Promise<number> => {
  return redis.del(key);
};